package com.zang.singleton;

/**
 * 双检索 #已被视为反模式，不推荐使用
 * volatile
 * @author Zhang Qiang
 * @Date 2019/9/20 11:42
 */
public class IncorrectDCLSingleton {
    private static volatile IncorrectDCLSingleton instance = null;
    private IncorrectDCLSingleton(){
        System.out.println("create IncorrectDCLSingleton");
    }

    public static IncorrectDCLSingleton getInstance(){
        if (instance == null){
            synchronized (IncorrectDCLSingleton.class){
                if (instance == null){
                    instance = new IncorrectDCLSingleton();
                }
            }
        }
        return instance;
    }

}
